<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.text.*"%>
<%@page import="java.util.*"%>
<%@page import="com.book.Dao.*"%>
<% 
response.setCharacterEncoding("utf-8");
String bookname=null;
String bookid=null;
String bookimg=null;
String bookprice=null;
String zuozhe=null;
String chubanshe=null;
String time=null;
String feileiid=null;

if(request.getParameter("bookname")!=null){
	bookname = new String(request.getParameter("bookname").getBytes("iso8859-1"),"utf-8"); 
}
SelectImg img=new SelectImg();
String newimg=img.findImg(bookname.trim());

if(request.getParameter("bookid")!=null){
	bookid = new String(request.getParameter("bookid").getBytes("iso8859-1"),"utf-8"); 
}

if(request.getParameter("bookprice")!=null){
	bookprice = new String(request.getParameter("bookprice").getBytes("iso8859-1"),"utf-8"); 
}
if(request.getParameter("zuozhe")!=null){
	zuozhe = new String(request.getParameter("zuozhe").getBytes("iso8859-1"),"utf-8"); 
}
if(request.getParameter("chubanshe")!=null){
	chubanshe = new String(request.getParameter("chubanshe").getBytes("iso8859-1"),"utf-8"); 
}
if(request.getParameter("time")!=null){
	time = new String(request.getParameter("time").getBytes("iso8859-1"),"utf-8"); 
}


if(request.getParameter("feileiid")!=null){
	feileiid = new String(request.getParameter("feileiid").getBytes("iso8859-1"),"utf-8"); 
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>book_desc.jsp</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" type="text/css" href="<c:url value='desc1.css'/>">
<link rel="stylesheet" type="text/css" href="<c:url value='/jquery/jquery.datepick.css'/>">
<script type="text/javascript" src="<c:url value='/jquery/jquery-1.5.1.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/jquery.datepick.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/jquery.datepick-zh-CN.js'/>"></script>
<script type="text/javascript" src="<c:url value='/jquery/desc.js'/>"></script>

<script type="text/javascript">
  //验证name
  function checkname(){
    var temp= document.getElementById("bname");
	var partten = /^[\u4E00-\u9FA5]+$/;
	if(temp.value!=""){
	if(!partten.test(temp.value)){
	alert('提示:请输入有效的name，只能是汉字！');
	bname.focus();
		return false ;
	}else{
		return false ;
	}
}
}
  
    //验证price
  function checkprice(){
    var temp= document.getElementById("currPrice");
	var partten = /^[0-9]+$/;
	if(temp.value!=""){
	if(!partten.test(temp.value)){
	alert('提示:请输入有效的价格，只能是整数！');
	currPrice.focus();
		return false ;
	}else{
		return false ;
	}
}
}
  //验证author
  function checkauther(){
    var temp= document.getElementById("author");
	var partten = /^[\u4E00-\u9FA5]+$/;
	if(temp.value!=""){
	if(!partten.test(temp.value)){
	alert('提示:请输入有效的作者，只能是汉字！');
	author.focus();
		return false ;
	}else{
		return false ;
	}
}
}

  //验证press
  function checkpress(){
    var temp= document.getElementById("press");
	var partten = /^[\u4E00-\u9FA5]+$/;
	if(temp.value!=""){
	if(!partten.test(temp.value)){
	alert('提示:请输入有效的作者，只能是汉字！');
	press.focus();
		return false ;
	}else{
		return false ;
	}
}
}


$(function() {
	$("#box").attr("checked", false);
	$("#formDiv").css("display", "none");
	$("#show").css("display", "");	
	
	// 操作和显示切换
	$("#box").click(function() {
		if($(this).attr("checked")) {
			$("#show").css("display", "none");
			$("#formDiv").css("display", "");
		} else {
			$("#formDiv").css("display", "none");
			$("#show").css("display", "");		
		}
	});
});

</script>
  </head>
  
  <body>
  
<div style="width:100%;height:100%; overflow-y:scroll; border:1px solid;">
    <input type="checkbox" id="box"><label for="box">编辑或删除</label>
    <br/>
    <br/>
  <div id="show">
    <div class="sm"><%=bookname.trim()%></div>
    <img align="top" src="<c:url value='<%=newimg%>'/>" class="tp"/>
    <div id="book" style="float:left;">
	    <ul>
	    	<li>商品编号：<%=bookid%></li>
	    	<li>当前价：<span class="price_n">&yen;<%=bookprice%></span></li>
	    	</ul>
		<hr style="margin-left: 50px; height: 1px; color: #dcdcdc"/>
		<table class="tab">
			<tr>
				<td colspan="3">
					作者：<%=zuozhe%>著
				</td>
			</tr>
			<tr>
				<td colspan="3">
					出版社：<%=chubanshe%></a>
				</td>
			</tr>
			<tr>
				<td colspan="3">出版时间：<%=time%></td>
			</tr>
		</table>
	</div>
  </div>
  
  
  <div id='formDiv'>
   <div class="sm">&nbsp;</div>
   <form action="javascript:alert('编辑或删除图书成功！')" method="post" id="form">
   	<input type="hidden" name="bid" value=""/>
   	<input type="hidden" name="image_w" value=""/>
   	<input type="hidden" name="image_b" value=""/>
    <img align="top" src="<c:url value='<%=newimg%>'/>" class="tp"/>
    <form action="../Delete">
    <div style="float:left;">
	    <ul>
	    	<li>商品编号：<%=bookid%></li>
	    	<input id="id" type="hidden" name="id" value="<%=bookid%>"/>
	    	<li>书名：　<input id="bname" type="text" name="bname" value="<%=bookname.trim()%>" onblur="checkname();" style="width:500px;"/></li>
	    	
	    <li>价格：<input id="currPrice" type="text" name="currPrice" value="<%=bookprice.trim()%>" onblur="checkprice();" style="width:50px;"/></li>
		<hr style="margin-left: 50px; height: 1px; color: #dcdcdc"/>
	    </ul>
		<table class="tab">
			<tr>
				<td colspan="3">
					作者：　　<input id="author" type="text" name="author" value="<%=zuozhe.trim()%>" onblur="checkauther();" style="width:150px;"/>
				</td>
			</tr>
			<tr>
				<td colspan="3">
					出版社：　<input id="press" type="text" name="press" value="<%=chubanshe.trim()%>" onblur="checkpress();" style="width:200px;"/>
				</td>
			</tr>
			<tr>
				<td colspan="3">出版时间：<input id="publishtime" type="text" name="publishtime" value="<%=time%>" style="width:100px;"/></td>
			</tr>
			<tr>
				<td>
					一级分类：<select name="pid" id="pid" onchange="loadChildren()">
					<%if("1".equals(feileiid)){ %>
			    		<option value="1" selected='selected'>小说故事</option>
			    		<option value="2">学习资料</option>
			    		<option value="3">IT书籍</option>
			    		<% }else if("2".equals(feileiid)){%>
			    	    <option value="1" >小说故事</option>
			    		<option value="2" selected='selected'>学习资料</option>
			    		<option value="3">IT书籍</option>
			    		<% }else if("3".equals(feileiid)){%>
			    		<option value="1" >小说故事</option>
			    		<option value="2">学习资料</option>
			    		<option value="3" selected='selected'>IT书籍</option>
			    		<%}%>
					</select>
				</td>
				<td></td>
			</tr>
			<tr>
				<td colspan="2">
					<input onclick="editForm()" type="button" value="编　　辑" id="editBtn" class="btn" style="background:red" >
					<a href="../Delete?id=<%=bookid%>" id="delBtn" class="btn2">删　　除</a>
					<!-- <input type="submit" value="删　　除" id="delBtn" class="btn2" > -->
				</td>
				<td></td>
			</tr>
		</table>
	</div>
   </form>
  </div>

  </body>
</html>
